Skip to content

Report nodes and nps summed over all search threads - #69

Merged
nook0110 merged 5 commits into
deploy-elofrom
total-nodes
Nov 12, 2026
Merged

nook0110 merged 5 commits into
deploy-elofrom
total-nodes

Conversation

@nook0110

Copy link
Copy Markdown
Owner

Stacked on #65. Merge #65 first, then retarget this PR to its base if GitHub does not do it automatically.

What changes

  • Reporting: info nodes and nps now count every search thread, as Stockfish does. Before, they counted only the main thread, so with Threads 4 the engine reported roughly a quarter of its real work.
  • Counter: each Searcher owns a NodeCounter. Only that thread writes it; the main engine reads every thread's counter when it prints info. Relaxed atomic load and store are enough because there is a single writer. They compile to the same add as a plain counter, unlike Stockfish's fetch_add, which needs a locked instruction.
  • Lifetime: SearchThread hands the helper engines to the main engine before the search starts and takes them back after the main thread is joined, so no counter is read after its engine is destroyed.
  • Unchanged: time management and EBF still use the main thread's own per-iteration counts, so the search and time decisions are unchanged.

Verification

  • Search identity: at depth 11 on 30 positions, every info line except nodes, nps and time is identical to UCI: go nodes, full node counts and FEN validation #65 with both GCC 15 and clang 23. Single-thread node totals are identical too: 7,274,560.

  • Threads: one position, 5 s per run, CPUs 16–19:

    Build Threads Reported nodes nps
    UCI: go nodes, full node counts and FEN validation #65 4 518,646 103,753
    this PR 1 1,035,895 207,188
    this PR 4 4,049,687 809,963

    These timings were taken while another build loaded the machine, so the nps values are low in absolute terms. The 4-thread total is about 3.9 times the single-thread one.

  • Machine code:

    • The counter is marked [[gnu::always_inline]]; without it GCC made a call per node.
    • GCC 15: each search-node function gains the three-instruction increment (mov, add, mov) plus register reshuffles, 5–10 instructions out of about 1,600 per function.
    • clang 23: the counter is inlined everywhere; the search-node functions change by −3 to +16 instructions.
  • Speed: wall-clock timing over five alternating rounds is within noise. The machine was loaded by an unrelated build, so this only rules out a large slowdown.

  • Tests:

    • 207 of 207 pass with GCC 15;
    • new NodeCounting.ReportsNodesOfAllThreads checks that the reported nodes equal the main thread's count plus the helper's.

🤖 Generated with Claude Code

nook0110 and others added 4 commits November 10, 2026 16:12
`info nodes` and `nps` counted only the main thread, so with Lazy SMP
they showed roughly one thread's share of the work. Each searcher now
owns a NodeCounter that only its thread writes, with relaxed atomic
loads and stores that compile to a plain add, and the main engine sums
its helpers' counters when it prints info, as Stockfish does. Time
management and EBF still use the main thread's own iteration counts,
so the search is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preserve total node publication across the updated search, quiescence and ProbCut paths. Isolate reporting-enabled search instantiations from ordinary-search LTO while sharing the typed search algorithm.

Bench: 993713
@nook0110
nook0110 changed the base branch from uci-nodes to deploy-elo November 12, 2026 20:34
Bench: 993713

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nook0110
nook0110 merged commit 7cf5331 into deploy-elo Nov 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant